package cn.doitedu.producer.low.datasources;

import java.io.*;
import java.util.Iterator;

public class FileDataSourceIter implements Iterator<String> {

    BufferedReader br;
    String line;

    public FileDataSourceIter(String path) throws Exception {
        this.br = new BufferedReader(new InputStreamReader(new FileInputStream(path), "utf-8"));
    }

    @Override
    public boolean hasNext() {
        try {
            line = br.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

        return line!=null;
    }

    @Override
    public String next() {
        return line;
    }
}
